/*
 * ButtonService.java
 *
 * Copyright 2012 the original author or authors(ninglong).
 *
 * Licensed under the web-geek, Version 1.0 (the "License");
 *
 */
package org.geek.app.button.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.geek.app.button.service.IButtonService;
import org.geek.core.mybatis.domain.Button;
import org.geek.core.mybatis.domain.Criteria;
import org.geek.core.mybatis.mapper.ButtonMapper;
import org.springframework.stereotype.Service;


/**
 * <p></p>
 * @author ninglong bhd2973@qq.com
 * @version V1.0
 */
@Service
public class ButtonService implements IButtonService {

	@Resource
	private ButtonMapper buttonMapper;
	
	public int countButtonByCriteria(Criteria criteria) {
		if(criteria==null)criteria = new Criteria();
		return buttonMapper.countButtonByCriteria(criteria);
	}

	public List<Button> getButtonByCriteria(Criteria criteria) {
		if(criteria==null)criteria = new Criteria();
		return buttonMapper.getButtonByCriteria(criteria);
	}

	public int modButton(Button button) {
		return buttonMapper.modButton(button);
	}

	public int addButton(Button button) {
		return buttonMapper.addButton(button);
	}

	public int delButtonByButtonId(int buttonId) {
		return buttonMapper.delButtonByButtonId(buttonId);
	}

	@Override
	public List<Button> getButtonByAuth(int moduleId, int userId) {
		Criteria criteria = new Criteria();
		criteria.put("moduleId", moduleId);
		criteria.put("userId", userId);
		return buttonMapper.getButtonByAuth(criteria);
	}

}
